#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <pwd.h>
#include <string.h>

static void my_alarm( int signo )
{
	struct passwd *rootptr;

	printf( "in signal handler\n" );
	if( ( rootptr = getpwnam( "root" ) ) == NULL )
		perror( "getpwnam(root) error" );
	printf( "%s", rootptr->pw_name );
	alarm( 1 );
}

int main( int argc, char *argv[] )
{
	struct passwd *ptr;

	signal( SIGALRM, my_alarm );
	alarm( 1 );

	while( 1 ) {
		if( (ptr = getpwnam( "liubin" )) == NULL )
			perror( "getpwnam error" );
		if( strcmp( ptr->pw_name, "liubin" ) != 0 )
			printf( "return value corruped, pw_name = %s", ptr->pw_name );
	}

	return 0;
}
